home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 44 / PC Actual CD 44.iso / Linux / Cygwin / full.exe / Disk1 / data1.cab / Tools / share / tix4.1 / demos / samples / CmpImg2.tcl < prev    next >
Encoding:
Text File  |  1998-12-04  |  4.3 KB  |  133 lines

  1. # Tix Demostration Program
  2. #
  3. # This sample program is structured in such a way so that it can be
  4. # executed from the Tix demo program "widget": it must have a
  5. # procedure called "RunSample". It should also have the "if" statment
  6. # at the end of this file so that it can be run as a standalone
  7. # program using tixwish.
  8.  
  9. # This file demonstrates how to use the compound image inside NoteBook
  10. # widgets. This file is basically a cross-over of NoteBook.tcl and CmpImg.tcl
  11. #
  12. proc RunSample {w} {
  13.  
  14.     # Create the notebook widget and set its backpagecolor to gray.
  15.     # Note that the -backpagecolor option belongs to the "nbframe"
  16.     # subwidget.
  17.     tixNoteBook $w.nb -ipadx 6 -ipady 6
  18.     $w config -bg gray
  19.     $w.nb subwidget nbframe config -backpagecolor gray -tabpady 0
  20.  
  21.     # Create the two compound images
  22.     #
  23.     #
  24.  
  25.     # these are two Tix built-in images
  26.     #
  27.     set img0 [tix getimage network]
  28.     set img1 [tix getimage harddisk]
  29.  
  30.     # Create the first image:
  31.     #
  32.     # Notice that the -window option must be set to the nbframe
  33.     # subwidget of the notebook because the image will be displayed
  34.     # in that widget.
  35.     #
  36.     set hdd_img [image create compound -window [$w.nb subwidget nbframe] \
  37.     -pady 0]
  38.     $hdd_img add line
  39.     $hdd_img add image -image $img1
  40.     $hdd_img add space -width 7
  41.     $hdd_img add text -text "Hard Disk" -underline 0
  42.  
  43.     # Create the second compound image. Very similar to what we did above
  44.     #
  45.     set net_img [image create compound -window [$w.nb subwidget nbframe] \
  46.     -pady 0]
  47.     $net_img add line
  48.     $net_img add image -image $img0
  49.     $net_img add space -width 7
  50.     $net_img add text -text "Network" -underline 0
  51.  
  52.     #
  53.     # Now create the pages
  54.     #
  55.  
  56.     # We use these options to set the sizes of the subwidgets inside the
  57.     # notebook, so that they are well-aligned on the screen.
  58.     #
  59.     set name [tixOptionName $w]
  60.     option add *$name*TixControl*entry.width 10
  61.     option add *$name*TixControl*label.width 18
  62.     option add *$name*TixControl*label.anchor e
  63.  
  64.     # Create the two tabs on the notebook. The -underline option
  65.     # puts a underline on the first character of the labels of the tabs.
  66.     # Keyboard accelerators will be defined automatically according
  67.     # to the underlined character.    
  68.     #
  69.     $w.nb add hard_disk -image $hdd_img
  70.     $w.nb add network   -image $net_img
  71.     pack $w.nb -expand yes -fill both -padx 5 -pady 5 -side top
  72.  
  73.     #----------------------------------------
  74.     # Create the first page
  75.     #----------------------------------------
  76.     set f [$w.nb subwidget hard_disk]
  77.  
  78.     # Create two frames: one for the common buttons, one for the
  79.     # other widgets
  80.     #
  81.     frame $f.f
  82.     frame $f.common
  83.     pack $f.f      -side left  -padx 2 -pady 2 -fill both -expand yes
  84.     pack $f.common -side right -padx 2 -pady 2 -fill y
  85.  
  86.     # Create the controls that only belong to this page
  87.     #
  88.     tixControl $f.f.a -value 12   -label "Access Time: "
  89.     tixControl $f.f.w -value 400  -label "Write Throughput: "
  90.     tixControl $f.f.r -value 400  -label "Read Throughput: "
  91.     tixControl $f.f.c -value 1021 -label "Capacity: "
  92.     pack $f.f.a $f.f.w $f.f.r $f.f.c  -side top -padx 20 -pady 2
  93.  
  94.     # Create the common buttons
  95.     #
  96.     CreateCommonButtons $w $f.common
  97.     
  98.     #----------------------------------------
  99.     # Create the second page    
  100.     #----------------------------------------
  101.     set f [$w.nb subwidget network]
  102.  
  103.     frame $f.f
  104.     frame $f.common
  105.     pack $f.f      -side left  -padx 2 -pady 2 -fill both -expand yes
  106.     pack $f.common -side right -padx 2 -pady 2 -fill y
  107.  
  108.     tixControl $f.f.a -value 12   -label "Access Time: "
  109.     tixControl $f.f.w -value 400  -label "Write Throughput: "
  110.     tixControl $f.f.r -value 400  -label "Read Throughput: "
  111.     tixControl $f.f.c -value 1021 -label "Capacity: "
  112.     tixControl $f.f.u -value 10   -label "Users: "
  113.  
  114.     pack $f.f.a $f.f.w $f.f.r $f.f.c $f.f.u -side top -padx 20 -pady 2
  115.  
  116.     CreateCommonButtons $w $f.common
  117. }
  118.  
  119. proc CreateCommonButtons {w f} {
  120.     button $f.ok     -text OK     -width 6 -command "destroy $w"
  121.     button $f.cancel -text Cancel -width 6 -command "destroy $w"
  122.  
  123.     pack $f.ok $f.cancel -side top -padx 2 -pady 2
  124. }
  125.  
  126. if {![info exists tix_demo_running]} {
  127.     wm withdraw .
  128.     set w .demo
  129.     toplevel $w
  130.     RunSample $w
  131.     bind .demo <Destroy> exit
  132. }
  133.